
// ChemGraphicsView.h : interface of the CChemGraphicsView class
//

#pragma once

#include "CRectangle.h"
#include "BaseShape.h"
#include "CCircle.h"
#include "CLine.h"
#include "CCurver.h"
#include "Arrow.h"
#include "CSquare.h"
#include "CEclipse.h"
#include "CDoubleBond.h"
#include "CTriBond.h"
#include "BenzenBond.h"
#include "CCycloHexaneBone.h"
#include "CCycloPentane.h"
#include "CSymbol.h"
#include "COneBond.h"
#include "CHasheWedge.h"
#include "CWedgeBond.h"
#include "CHashBond.h"
#include "CTriBond.h"
#include "CCycloPropane.h"
#include "CCycloPutane.h"
#include "CObitalCircle.h"
#include "CObitalBold.h"
#include "CObitalEsclipe.h"
#include "CObitalEsclipeBold.h"
#include "CObitalPie.h"
#include "CObitalPieBold.h"
#include "CObitalEsclipeBold.h"
#include "CObitalFlower.h"
#include "CObitalFlowerBold.h"
#include "ObitalSmallFlower.h"
#include "CObitalBSmallFlower.h"
#include "BenzenBond.h"
#include "CCircleBenzene.h"
#include "CWhiteHashBond.h"
#include "CUndefineBond.h"
#include "CDoubleArrow.h"
#include "CBoldBond.h"
#include "CDoubleBoldBond.h"
#include "CText.h"
class CChemGraphicsView : public CScrollView
{
protected: // create from serialization only
	CChemGraphicsView();
	DECLARE_DYNCREATE(CChemGraphicsView)

// Attributes

public:
	CChemGraphicsDoc* GetDocument() const;
	CDC m_dcMem;
	CBitmap m_bmpMem;
	BOOL m_bFlagMove; //duoc bat len khi chon hinh de di chuyen
	CPoint m_pTBegin;
	CPoint m_pTEnd;
	CPoint m_pVetor;
	CPoint m_posMouse;
	BOOL m_bFlagShape;

	//*********Phan bo sung cua Tri*****************//
	COLORREF m_cPenColor;	//mau net ve cua shape
	CRect m_rDrag;
// Operations
public:
	void RedrawCaret();
	void CreateNewCaret(BOOL);
	void HomeCaret(); 
	void EndCaret();
	void ForwardCaretToBlank();
	void BackwardCaretToBlank(); 
	void SetCaret(CPoint);
// Overrides
public:
	virtual void OnDraw(CDC* pDC);  // overridden to draw this view
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
	virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
	virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
	virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
private:
	void ShowErrorWin32();
	void ShowErrorGdiplus(int iStatus);
	int GetEncoderClsid(const WCHAR * wszEncoder, CLSID * pClsid);
	void ExportToPicture();
	void ExportToPicture(CRect);
// Implementation
public:
	virtual ~CChemGraphicsView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:
// Generated message map functions
protected:
	afx_msg void OnFilePrintPreview();
	afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
	DECLARE_MESSAGE_MAP()
public:
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	virtual void OnUpdate(CScrollView* /*pSender*/, LPARAM /*lHint*/, CObject* /*pHint*/);
	afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
	afx_msg void OnUpdateIndicatorPos(CCmdUI *pCmdUI);
	afx_msg void OnToolsColortable();
	virtual void OnInitialUpdate();
	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnToolsFillcolor();
};

#ifndef _DEBUG  // debug version in ChemGraphicsView.cpp
inline CChemGraphicsDoc* CChemGraphicsView::GetDocument() const
   { return reinterpret_cast<CChemGraphicsDoc*>(m_pDocument); }
#endif

